package com.wxsong.authplatform.authweb.util;

import java.io.Serializable;
import java.util.Map;

public class Response implements Serializable {

    protected boolean success;
    protected String code;
    protected String info;
    protected Map data;

    public Response() {
    }

    public Response(boolean success, String info, Map data) {
        this.success = success;
        this.info = info;
        this.data = data;
    }
    public Response(boolean success, String code, String info, Map data) {
        this.success = success;
        this.code = code;
        this.info = info;
        this.data = data;
    }

    public static Response fail(String info){
        return new Response(false, info, null);
    }
    public static Response fail(String code, String info){
        return new Response(false, code, info, null);
    }
    public static Response fail(ResponseCode responseCode){
        return new Response(false, responseCode.code, responseCode.info, null);
    }

    public static Response success(){
        return new Response(true, ResponseCode.SUCCESS.info, null);
    }
    public static Response success(ResponseCode responseCode){
        return new Response(true, responseCode.code, responseCode.info, null);
    }
    public static Response success(ResponseCode responseCode, Map data){
        return new Response(true, responseCode.code, responseCode.info, data);
    }
    public static Response success(String info){
        return new Response(true, info, null);
    }
    public static Response success(Map data){
        return new Response(true, ResponseCode.SUCCESS.info, data);
    }
    public static Response success(String info, Map data){
        return new Response(true, info, data);
    }

    public boolean isSuccess() {
        return success;
    }

    public Response setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public String getCode() {
        return code;
    }

    public Response setCode(String code) {
        this.code = code;
        return this;
    }

    public String getInfo() {
        return info;
    }

    public Response setInfo(String info) {
        this.info = info;
        return this;
    }

    public Map getData() {
        return data;
    }

    public Response setData(Map data) {
        this.data = data;
        return this;
    }
}
